# -*- coding: utf-8 -*-
# Create your views here.
from cmsdj.content.models import Content
#from cmsdj.categories.models import Category
from cmsdj.cfg.models import SiteCfg
from django.shortcuts import render_to_response
from django.core.paginator import Paginator, EmptyPage, InvalidPage
from django.template.context import RequestContext

def index (request, page=1):
#    contents = Content.get_by_date_modified()
    contents = Content.get_by_date_created()

    paginator = Paginator(contents, 6)

    try:
        page_contents = paginator.page(page)
    except (EmptyPage, InvalidPage):
        page_contents = paginator.page(paginator.num_pages)
    print SiteCfg.current_cfg().template
    return render_to_response ( SiteCfg.current_cfg().template + '/base.html', {'page_contents': page_contents}, context_instance=RequestContext(request))
